Skip to content

Run clang-format in the test suite rather than as a separate CI step#218

Merged
wkearn merged 6 commits into
TopoToolbox:mainfrom
wkearn:cmake-clang-format
Mar 12, 2026
Merged

Run clang-format in the test suite rather than as a separate CI step#218
wkearn merged 6 commits into
TopoToolbox:mainfrom
wkearn:cmake-clang-format

Conversation

@wkearn
Copy link
Copy Markdown
Member

@wkearn wkearn commented Mar 12, 2026

This change simplifies the CI configuration and makes it somewhat easier to verify code formatting locally. Running the tests with ctest will run the format check after all the other tests have completed.

The format check is on by default unless clang-format cannot be found on the user's system. It can be turned off by passing -DTT_FORMAT_CHECK=0 to the CMake configuration step.

Any new tests must currently be added manually to the FORMAT_TARGETS list. The only consequence of failing to update the list is that the formatting check will not be run on the necessary test sources. The libtopotoolbox sources will still be checked.

I have also added internal header files to the various library/executable targets. This seems not to break anything and is necessary to get them checked as well.

This required some fiddling with the CI configuration to ensure that if the snapshot tests are not built because GDAL is missing then the clang-format configuration step doesn't try to look at the nonexistent snapshot target.

@bgailleton: Do you prefer having a separate CI job for the formatting checks? I am hoping that this makes it easier to get the formatting right locally because you don't have to remember the exact clang-format incantation, but it might hide formatting errors in the test output.

wkearn added 6 commits March 12, 2026 11:11
This change simplifies the CI configuration and makes it somewhat
easier to verify code formatting locally. Running the tests with ctest
will run the format check after all the other tests have completed.

The format check is on by default unless clang-format cannot be found
on the user's system. It can be turned off by passing
-DTT_FORMAT_CHECK=0 to the CMake configuration step.

Any new tests must currently be added manually to the FORMAT_TARGETS
list. The only consequence of failing to update the list is that the
formatting check will not be run on the necessary test sources. The
libtopotoolbox sources will still be checked.

I have also added internal header files to the various
library/executable targets. This seems not to break anything and is
necessary to get them checked as well.

Signed-off-by: William Kearney <william.kearney@uni-potsdam.de>
The snapshot tests won't run on Windows or macOS because they don't
have GDAL, but this prevents them trying to download the snapshot data
anyway.
@bgailleton
Copy link
Copy Markdown
Contributor

@wkearn your new approach seems simpler! I prefer the new everything-in-one version, we don't write tests that often so it should not be a problem

@wkearn
Copy link
Copy Markdown
Member Author

wkearn commented Mar 12, 2026

I will merge this then. Let me know if it does prove to be burdensome or if it is more flaky or unreliable this way.

@wkearn wkearn merged commit 092476c into TopoToolbox:main Mar 12, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants